Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo/boards Render hangs for multiple messages in avl.Tree #1727

Closed
jefft0 opened this issue Mar 4, 2024 · 3 comments
Closed

demo/boards Render hangs for multiple messages in avl.Tree #1727

jefft0 opened this issue Mar 4, 2024 · 3 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@jefft0
Copy link
Contributor

jefft0 commented Mar 4, 2024

demo/boards Render hangs for multiple messages in the avl.Tree

Description

If we change r/demo/boards RenderBoard to first put the posts in an avl.Tree, then Render works for 1050 messages, but hangs after adding another 150 messages.

Here is a video (less than 5 minutes) of reproducing the bug with the following steps.
https://www.loom.com/share/8815320be5674f39b788da0bd8d92aa6

Your environment

  • macOS Ventura 13.6.3
  • latest gnolang/gno as of 2024-03-01 6c5b4cf

Steps to reproduce

  1. Clone gno and install:
git clone https://github.com/gnolang/gno
cd gno
make install.gnodev
cd gno.land
make install
  1. If you haven't already done so, add the test_1 key to gnokey. Use the following command, enter a password, repeat the password, and enter the mnemonic "source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast".
gnokey add -recover test_1
  1. cd to the boards realm folder gno/examples/gno.land/r/demo/boards and edit public.gno. Comment out this line so that we can call CreateThread from a Run command.
  2. Edit board.gno and replace RenderBoard with the following which does the same thing, but first adds the messages to an avl.Tree.
func (board *Board) RenderBoard() string {
	allPosts := avl.Tree{} // postTime -> *Post
	board.threads.Iterate("", "", func(id string, postI interface{}) bool {
		allPosts.Set(id, postI.(*Post))
		return false
	})

	str := ""
	str += "\\[[post](" + board.GetPostFormURL() + ")]\n\n"
	allPosts.Iterate("", "", func(id string, postI interface{}) bool {
		str += "----------------------------------------\n"
		str += postI.(*Post).RenderSummary() + "\n"
		return false
	})
	return str
}
  1. Start gnodev
gnodev
  1. In another terminal, register test_1 and create a board:
gnokey maketx call -pkgpath "gno.land/r/demo/users" -func "Register" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "200000000ugnot" -broadcast -chainid tendermint_test -args "" -args "test_1" -args "profile" -remote "localhost:36657" test_1
gnokey maketx call -pkgpath "gno.land/r/demo/boards" -func "CreateBoard" -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "tendermint_test" -args "testboard" -remote "tcp://0.0.0.0:36657" test_1
  1. We want to use Run to add multiple messages. Create a file add150.gno with the following code which calls CreateThread 150 times. (This is the most we can add with the maximum gas allowed.):
package main

import (
	"gno.land/p/demo/ufmt"
	"gno.land/r/demo/boards"
)

func main() {
	for i := 1; i <= 150; i++ {
		boards.CreateThread(1, "title", ufmt.Sprintf("Hello %d", i))
	}
}
  1. Add 1050 messages by entering the following Run command 7 times:
gnokey maketx run test_1 add150.gno -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid "tendermint_test" -remote "tcp://0.0.0.0:36657"
  1. To invoke our modified RenderBoard, in a browser go to http://localhost:8888/r/demo/boards:testboard . You can see that the page loads quickly with all 1050 messages.
  2. Now, enter the Run command above to add another 150 messages. Refresh the browser page.

Expected behaviour

The RenderBoard function renders 1050 messages quickly with no problem. It should be able render quickly after adding another 150 messages.

Actual behaviour

But after adding another 150 messages, the RenderBoard function doesn't return. The web page just keeps waiting. It doesn't time out. Interestingly, gnodev itself is still alive. I can press h to get the help page.

Proposed solution

As a minimum, I hope to work with @gfanton to be able to reproduce the error. (This bug report uses r/demo/boards, but we have a similar problem in GnoSocial which is how we discovered it.)

@jefft0 jefft0 changed the title demo/boards Render fails for multiple message demo/boards Render hangs for multiple messages in avl.Tree Mar 4, 2024
@zivkovicmilos zivkovicmilos self-assigned this Mar 4, 2024
@zivkovicmilos zivkovicmilos added the 🐞 bug Something isn't working label Mar 4, 2024
@zivkovicmilos
Copy link
Member

@jefft0

Thank you for opening up the issue, I'll look into this issue and let you know what I find / fix 🙏

@jefft0
Copy link
Contributor Author

jefft0 commented Mar 4, 2024

You're welcome, @zivkovicmilos . As we discussed, I'm trying to turn this into an integration test with txtar, maybe to simplify so that it doesn't depend on r/demo/boards. I'm trying to narrow down the test. I may just be a case where the CPU times out, but the GnoVM doesn't handle it properly.

@jefft0
Copy link
Contributor Author

jefft0 commented Mar 5, 2024

Hi @zivkovicmilos . I created PR #1736 with a txtar that reproduces the hang in Render. I will close this issue and we can continue discussion there.

@jefft0 jefft0 closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants