gvanem / Watt-32

Watt-32 TCP/IP library and samples.
https://www.watt-32.net/
18 stars 8 forks source link

Speed up DHCP bootstrap #97

Closed jwt27 closed 8 months ago

jwt27 commented 8 months ago

Was looking into the DHCP issue (#4) and noticed this potential improvement (that you already hinted at). While waiting for a DHCP response, we can call dhcp_fsm() directly, and then later install it as a daemon for lease renewal. On my network, this speeds up DHCP configuration from ~4 seconds to almost-instantaneous.

This may appear to "fix" #4, but does not solve the underlying issue (that daemon processes seemingly won't run on 16-bit).

gvanem commented 8 months ago

This great news indeed! I'll try it tomorrow and report back.

Lethja commented 8 months ago

Might be a good idea to add another entry to the changelog at the top of the source code so future developers know this is a version with working DHCP

  *  \version 0.94: Oct 22, 2007:
  *    Fixes for Linux dhcp servers: parse dhcp options in ACK msgs.
  *    Changed DHCP_do_boot() to handle renew and rebind as well as init.
  *    Renegotiate lease if past the renew or rebind times.
+ * 
+ *  \version 0.95: Dec 20, 2023:
+ *    J.W. Jagersma - Improved DHCP bootstrap performance
+ *                  - Improved DHCP daemon stability on non-Pentium builds
 */
Lethja commented 8 months ago

16-bit (Watcom) output:

Parsing `.\wattcp.cfg' (pass 1)
Parsing `.\wattcp.cfg' (pass 2)
ARG_FUNC   , matched `MY_IP' = `dhcp'
rundown_dump():
  order   3: `restore_sig_handlers'  called from sock_ini.c (892)
  order   5: `dbug_exit'  called from pcdbug.c (306)
  order  10: `__eth_release'  called from pcsed.c (704)
  order 259: `DHCP_exit'  called from pcdhcp.c (1439)
  order 303: `exit_localport'  called from ports.c (59)
  order 1000: `daemon_clear_cdecl'  called from sock_ini.c (841)
  okay
Configuring through DHCP..Running daemon 0 (arp_daemon)
value 3232235779 duplicated in array 3626:3ed8

Address: 192.168.1.29
Calling rundown-func `restore_sig_handlers' at order 3
Calling rundown-func `dbug_exit' at order 5
Calling rundown-func `__eth_release' at order 10
Calling rundown-func `DHCP_exit' at order 259
Calling rundown-func `exit_localport' at order 303
Calling rundown-func `daemon_clear_cdecl' at order 1000
gvanem commented 8 months ago

Might be a good idea to add another entry to the changelog at the top

I'll do that after a merge.

gvanem commented 8 months ago

I'll do that after a merge.

Done that now in https://github.com/gvanem/Watt-32/commit/bef5e3acde1d9f02c6047484804f90429bf8fe75.

jwt27 commented 8 months ago

Might be a good idea to add another entry to the changelog at the top of the source code so future developers know this is a version with working DHCP

  *  \version 0.94: Oct 22, 2007:
  *    Fixes for Linux dhcp servers: parse dhcp options in ACK msgs.
  *    Changed DHCP_do_boot() to handle renew and rebind as well as init.
  *    Renegotiate lease if past the renew or rebind times.
+ * 
+ *  \version 0.95: Dec 20, 2023:
+ *    J.W. Jagersma - Improved DHCP bootstrap performance
+ *                  - Improved DHCP daemon stability on non-Pentium builds
 */

I don't really think it's necessary, since we have everything in git logs now (although I could at times be more descriptive in my commit messages...)

The second changelog entry would be wrong though, as I haven't done anything about timer stability (yet) :)