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

Support a single client connecting to multiple servers/processes #248

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/Remotery.c
Original file line number Diff line number Diff line change
Expand Up @@ -6341,6 +6341,16 @@ static rmtError Remotery_SendLogTextMessage(Remotery* rmt, Message* message)
return RMT_ERROR_NONE;
}

static rmtError bin_SamplesStart(Buffer* buffer, rmtU64 counter_start)
{
rmtU32 write_start_offset;
rmtTry(bin_MessageHeader(buffer, "SSST", &write_start_offset));
rmtTry(Buffer_WriteU64(buffer, counter_start));
rmtTry(bin_MessageFooter(buffer, write_start_offset));

return RMT_ERROR_NONE;
}

static rmtError bin_SampleName(Buffer* buffer, const char* name, rmtU32 name_hash, rmtU32 name_length)
{
rmtU32 write_start_offset;
Expand Down Expand Up @@ -6899,6 +6909,14 @@ static rmtError Remotery_ReceiveMessage(void* context, char* message_data, rmtU3

break;
}

case FOURCC('G', 'S', 'S', 'T'): {
Buffer* bin_buf = rmt->server->bin_buf;
WebSocket_PrepareBuffer(bin_buf);
bin_SamplesStart(bin_buf, rmt->timer.counter_start);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why any of the tests aren't picking this up, but this should be rmt->timer.counter_start.QuadPart.


return Server_Send(rmt->server, bin_buf->data, bin_buf->bytes_used, 10);
}
}

#undef FOURCC
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Running the Viewer

Double-click or launch `vis/index.html` from the browser.

Use Bash-like brace expansions in the `Connection Address Pattern` field to view multiple processes.


Sampling CUDA GPU activity
--------------------------
Expand Down
22 changes: 12 additions & 10 deletions vis/Code/Console.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Console = (function()
var HEIGHT = 200;


function Console(wm, server)
function Console(wm)
{
// Create the window and its controls
this.Window = wm.AddWindow("Console", 10, 10, 100, 100);
Expand Down Expand Up @@ -33,15 +33,17 @@ Console = (function()
// At a much lower frequency this will update the console window
window.setInterval(Bind(UpdateHTML, this), 500);

// Setup log requests from the server
this.Server = server;
server.SetConsole(this);
server.AddMessageHandler("LOGM", Bind(OnLog, this));

this.Window.SetOnResize(Bind(OnUserResize, this));
}


Console.prototype.SetServer = function(server)
{
// The server which will be receiving the console input.
this.Server = server;
}


Console.prototype.Log = function(text)
{
this.PageTextBuffer = LogText(this.PageTextBuffer, text);
Expand All @@ -65,15 +67,15 @@ Console = (function()
}


function OnLog(self, socket, data_view_reader)
Console.prototype.OnLog = function(server, socket, data_view_reader)
{
var text = data_view_reader.GetString();
self.AppTextBuffer = LogText(self.AppTextBuffer, text);
this.AppTextBuffer = LogText(this.AppTextBuffer, text);

// Don't register text as updating if disconnected as this implies a trace is being loaded, which we want to speed up
if (self.Server.Connected())
if (server.Connected())
{
self.AppTextUpdatePending = true;
this.AppTextUpdatePending = true;
}
}

Expand Down
18 changes: 9 additions & 9 deletions vis/Code/NameMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class NameMap
this.textBuffer = text_buffer;
}

Get(name_hash)
Get(server_id, name_hash)
{
// Return immediately if it's in the hash
let name = this.names[name_hash];
let name = this.names[[server_id, name_hash]];
if (name != undefined)
{
return [ true, name ];
Expand All @@ -18,27 +18,27 @@ class NameMap
// Create a temporary name that uses the hash
name = {
string: name_hash.toString(),
hash: name_hash
hash: [server_id, name_hash]
};
this.names[name_hash] = name;
this.names[[server_id, name_hash]] = name;

// Add to the text buffer the first time this name is encountered
name.textEntry = this.textBuffer.AddText(name.string);

return [ false, name ];
}

Set(name_hash, name_string)
Set(server_id, name_hash, name_string)
{
// Create the name on-demand if its hash doesn't exist
let name = this.names[name_hash];
let name = this.names[[server_id, name_hash]];
if (name == undefined)
{
name = {
string: name_string,
hash: name_hash
hash: [server_id, name_hash]
};
this.names[name_hash] = name;
this.names[[server_id, name_hash]] = name;
}
else
{
Expand All @@ -50,4 +50,4 @@ class NameMap

return name;
}
}
}
Loading