Ticket #1818 (accepted defect) — at Version 17

Opened 14 years ago

Last modified 14 years ago

Refactoring no-vfs

Reported by: metux Owned by: metux
Priority: major Milestone: 4.7.4
Component: mc-vfs Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: Votes for changeset:

Description (last modified by metux) (diff)

Building w/o VFS seems quite a bit broken now.
Refactoring it, eg. moving stuff from src/vfsdummy.h into vfs/vfs.h and get rid of some #ifdef VFS

branch:1818_refactoring_no_vfs_METUX

Change History

comment:1 Changed 14 years ago by andrew_b

  • Component changed from mc-core to mc-vfs

comment:2 Changed 14 years ago by metux

  • Keywords vfs no-vfs added
  • Status changed from new to accepted
  • severity changed from no branch to on review
  • Owner set to metux
  • Description modified (diff)

comment:3 Changed 14 years ago by andrew_b

  • severity changed from on review to on rework

vfs/vfs.h

223	    p = strdup (p); 

254	#endif                          /* MC_VFSDUMMY_H */

Please fix that.

And use g_strdup() instead of strdup() and g_snprintf() instead of snprintf().

comment:4 Changed 14 years ago by metux

In which way is g_strdup()/g_snprint() better than strdup()/snprintf(), despite being slower ?

comment:5 Changed 14 years ago by andrew_b

Actually, in most cases (99%) that glib functions are used in MC.

comment:6 follow-up: ↓ 8 Changed 14 years ago by metux

That doesnt change the fact, that these two functions are nothing but slow wrappers, without any technical benetif it that case.

Just look at the source:
g_snprintf() calls g_vsnprintf() calls vsnprintf()

Calling snprintf() is the direct way. And a clever compiler can
optimize much more (eg. inlining statically predictable cases).

comment:7 Changed 14 years ago by andrew_b

Just look at glibc source. You'll see the same way.

comment:8 in reply to: ↑ 6 Changed 14 years ago by andrew_b

Replying to metux:

That doesnt change the fact, that these two functions are nothing but slow wrappers,

OK, let's compare:

#include <stdio.h>
#include <sys/types.h>

int
main (int argc, char *argv[])
{
 size_t i, j;
 char buf[32];

 for (i = 0; i < 10000; i++)
     for (j = 0; j < 10000; j++)
         snprintf (buf, sizeof (buf), "%ll", i + j);

 return 0;
}

/* Result:
   $ time ./test-snprintf
   9.50user 0.00system 0:09.51elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
   0inputs+0outputs (0major+114minor)pagefaults 0swaps
*/
#include <sys/types.h>
#include <glib.h>

int
main (int argc, char *argv[])
{
 size_t i, j;
 char buf[32];

 for (i = 0; i < 10000; i++)
     for (j = 0; j < 10000; j++)
         g_snprintf (buf, sizeof (buf), "%ll", i + j);

 return 0;
}

/* Result:
   $ time ./test-gsnprintf
   10.14user 0.00system 0:10.15elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
   0inputs+0outputs (0major+137minor)pagefaults 0swaps
*/

Tested on Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz

Yes, slower by 0.6 s for 100,000,000 iterations. Is it too much for you?

comment:9 follow-up: ↓ 10 Changed 14 years ago by andrew_b

  • Description modified (diff)

Enrico, you stubbornly replace glib functions. I don't thing that you will give any votes for your changes.

comment:10 in reply to: ↑ 9 Changed 14 years ago by andrew_b

Replying to andrew_b:

I don't thing that you will give any votes for your changes.

s/give/get
of course. Sorry...

comment:11 Changed 14 years ago by andrew_b

Sorry, too many typos. My morning is not very well...

I don't thing that you will give any votes for your changes.

I don't think that you will get any votes for your changes.

comment:12 Changed 14 years ago by slavazanko

  • severity changed from on rework to on review

Well... In branch was huge work. It's great. But I have some proposal:

a34369f96646c35bc01ee09fa75ae44be3478bd1::

configure.ac: Added check for empty value of 'enable_mcserver' variable for more proper summary output.

d31b2e86191ee5ea61dfe4e4b55962a1b6a698f5::

Remove support of mvfs. Need to start anoter task for adding them into project. Just keep in mind this changeset if need revert in future. At present time we don't have mvfs support. See #1829 for more details

e4f78f2a928ff5d9bad8b93e8bdf00ed2a9e0bf2::

Replaced free() via g_free() function for one-style codetyping. Please, use g_* functions if this possible.

5c0af26f3bcbd8da915859307fe3323522ae2e84::

Added author of 'vfs/netutil.c' file (but not author of functions in this file :) )

Also, no need to rebase branch at any time of change 'master' branch. In ideal case this branch should be rebased before merge in 'master' branch. Please, don't often rebase branches.

Review, please.

comment:13 Changed 14 years ago by metux

As I'm still reworking w/ lots of rebasing, I've almost overwritten your changes by accident ;-O

So I've moved to the 1818_refactoring_no_vfs_METUX branch. Don't touch it - it will be overwritten ;-P

I'll let you know when I'm done and everything runs through the build matrix.

comment:14 Changed 14 years ago by slavazanko

  • severity changed from on review to on rework

:) okay, awaiting...

comment:15 Changed 14 years ago by metux

Okay, finished for now and testbuilds succeed.

For additions better chose a different branch name :)

comment:16 Changed 14 years ago by metux

  • Milestone changed from 4.7 to 4.7.0

comment:17 Changed 14 years ago by metux

  • Description modified (diff)
  • severity changed from on rework to on review

rebased to current master, running through testfarm.

Note: See TracTickets for help on using tickets.